﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:Common="clr-namespace:Snipps.Infrastructure" xmlns:Controls="clr-namespace:Snipps.Controls">

    <ResourceDictionary.MergedDictionaries>
        <Common:SharedResourceDictionary Source="/Snipps;component/Resources/BaseControlStyles/TextBoxStyle.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style BasedOn="{StaticResource {x:Type TextBox}}"
           TargetType="{x:Type Controls:BusyTextBox}">

        <Setter Property="WatermarkBrush" Value="{DynamicResource DisableBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Controls:BusyTextBox}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight}" />
                            </Grid.ColumnDefinitions>
                            <ScrollViewer x:Name="PART_ContentHost"
                                          Grid.Column="0" />
                            <TextBlock x:Name="PART_Watermark"
                                       Grid.Column="0"
                                       Margin="2,0,0,0"
                                       FontStyle="Italic"
                                       Foreground="{TemplateBinding WatermarkBrush}"
                                       Text="{TemplateBinding WatermarkText}"
                                       Visibility="Collapsed" />
                            <Controls:CircuralIndicator x:Name="PART_Progressbar"
                                                        Grid.Column="1"
                                                        IsTabStop="False"
                                                        Visibility="Collapsed"
                                                        Color="{DynamicResource ForegroundColor}" />

                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSearching" Value="true">
                            <Setter TargetName="PART_Progressbar" Property="Visibility" Value="Visible" />
                        </Trigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsFocused" Value="False" />
                                <Condition Property="Text" Value="" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter TargetName="PART_Watermark" Property="Visibility" Value="Visible" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>